﻿using System;
using System.Web.Mvc;
using System.Web;
using System.Web.Security;

namespace MvcWebUI.Filters
{
    public class LoginAuthorizeAttribute : AuthorizeAttribute
    {

        public override void OnAuthorization(AuthorizationContext context)
        {
            HttpContextBase httpContext = context.HttpContext;
            if (context == null)
                throw new ArgumentNullException("filterContext");


            if (httpContext.Session["Login"] == null)
            {
                                context.Result = new RedirectToRouteResult(
                                 new System.Web.Routing.RouteValueDictionary { 
                                    { "controller", "Home" }
                                    
                             });
            }

        }
    }
}
